# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-beetle-saturn
pkgver=1.22.2.18
_realname=Matrix
pkgrel=1
pkgdesc="Beetle-Saturn for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.beetle-saturn"
arch="x86 x86_64 aarch64 armv7" # kodi
license="GPL-2.0-only"
makedepends="cmake kodi-dev"
depends="kodi-game-libretro libretro-beetle-saturn"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.beetle-saturn/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.beetle-saturn-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-saturn/resources/icon.png \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-saturn/game.libretro.beetle-saturn.so
	ln -s /usr/lib/libretro/mednafen_saturn_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-saturn/game.libretro.beetle-saturn.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-saturn/addon.xml
}

sha512sums="7e8e7074891a5dc49670cbf1849f1d5c51028466a3b2284bf6cb8ad921d377a504ffc0700de08d8aa938eccea359fecf98175f873a92daa1aeb216eaaa1c1c33  kodi-game-libretro-beetle-saturn-1.22.2.18-Matrix.tar.gz"
